$(function () {
    var meetingNum = GetQueryString("meeting");
    var userNum = GetQueryString("user");
    var params = JSON.stringify({"conventionerId": userNum, "conferenceId": meetingNum});
    $.ajax({
        // url:'http://125.65.40.171/conference-check/conferenceController/selectConferenceByIds',
        url: 'conferenceController/selectConferenceByIds',
        dataType: 'json',
        data: {"param": params},
        type: "post",
        xhrFields: {
            withCredentials: true
        },
        crossDomain: true,
        success: function (data) {
            if (data.code == 200) {
                $.each(data.data.conference, function (e, v) {
                    var applyTime = v.date;
                    var checkFlg = "";
                    var reason = "";
                    if (v.isApproved == 0) {
                        checkFlg = "未通过";
                    } else if (v.isApproved == 1) {
                        checkFlg = "已通过";
                    } else if (v.isApproved == 2) {
                        checkFlg = "审核中";
                    }
                    if (v.reason == null) {
                        reason = "";
                    } else {
                        reason = v.reason;
                    }
                    $(".contents-title").text(v.name);
                    $("#meeting_time").text(applyTime);
                    $("#meeting_cycle").text(v.cycle);
                    $("#meeting_cost").text(v.cost + "人民币");
                    $("#meeting_payAccount").text(v.payAccount);
                    $("#meeting_amountOfPay").text(v.amountOfPay);
                    $("#meeting_isApproved").text(checkFlg);
                    $("#meeting_remark").text(reason);
                    // $(".items_img").attr("src","http://125.65.40.171//conference-check/imageController/showIamgeFromServer?type=1&identifyId="+v.id);
                    $(".items_img").attr("src", "imageController/showIamgeFromServer?type=1&identifyId=" + v.id);
                });
                $.each(data.data.branches, function (e, v) {
                    var date = v.date;
                    // var endTime = new Date(v.endDate).Format("yyyy/MM/dd HH:mm");
                    var signFlg = "";
                    if (v.status == 0) {
                        signFlg = "未签到";
                    } else if (v.status == 1) {
                        signFlg = "已签到";
                    }
                    $(".time-contents").append("<li class='accordion-item'>" +
                        "<a href='#' class='item-content item-link'>" +
                        "<div class='item-inner'>" +
                        "<div class='item-title'>" + date + "</div>" +
                        "</div>" +
                        "</a>" +
                        "<div class='accordion-item-content'>" +
                        "<div class='content-block'>" +
                        "<div class='block accordion-list custom-accordion'>" +
                        "<div class='accordion-item'>" +
                        "<div class='accordion-item-toggle'>" +
                        "<i class='icon-change fa fa-plus-square'></i>" +
                        "<span>参会地点</span>" +
                        "</div>" +
                        "<div class='accordion-item-content'>" +
                        "<p>" + v.site + "</p>" +
                        "</div>" +
                        "</div>" +
                        "<div class='accordion-item'>" +
                        "<div class='accordion-item-toggle'>" +
                        "<i class='icon-change fa fa-plus-square'></i>" +
                        "<span>签到状态</span>" +
                        "</div>" +
                        "<div class='accordion-item-content'>" +
                        "<p>" + signFlg + "</p>" +
                        "</div>" +
                        "</div>" +
                        "<div class='accordion-item'>" +
                        "<div class='accordion-item-toggle'>" +
                        "<i class='icon-change fa fa-plus-square'></i>" +
                        "<span>会议内容</span>" +
                        "</div>" +
                        "<div class='accordion-item-content'>" +
                        "<p>" + v.content + "</p>" +
                        "</div>" +
                        "</div>" +
                        "<div class='accordion-item'>" +
                        "<div class='accordion-item-toggle'>" +
                        "<i class='icon-change fa fa-plus-square'></i>" +
                        "<span>参会嘉宾</span>" +
                        "</div>" +
                        "<div class='accordion-item-content'>" +
                        "<p>" + v.distinguishedGuest + "</p>" +
                        "</div>" +
                        "</div>" +
                        "</div>" +
                        "</div>" +
                        "</div>" +
                        "</li>");
                });
                $(".item-link").on("click", function () {
                    if ($(this).parent().hasClass("accordion-item-expanded")) {
                        $(this).parent().removeClass("accordion-item-expanded");
                    } else {
                        $(this).parent().addClass("accordion-item-expanded");
                    }
                });
                $(".accordion-item-toggle").on("click", function () {
                    if ($(this).parent().hasClass("accordion-item-expanded")) {
                        $(this).parent().removeClass("accordion-item-expanded");
                        $(this).find(".icon-change").removeClass("fa fa-minus-square");
                        $(this).find(".icon-change").addClass("fa fa-plus-square");
                    } else {
                        $(this).parent().addClass("accordion-item-expanded");
                        $(this).find(".icon-change").removeClass("fa fa-plus-square");
                        $(this).find(".icon-change").addClass("fa fa-minus-square");
                    }
                })
            }
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            myApp.alert('', '系统错误，请稍后重试');
        }
    })
});

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}